using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Usercontrols_PageEditor2 : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (string.IsNullOrEmpty(Request.QueryString["pageId"] as string))
            {
                FormView1.DefaultMode = FormViewMode.Insert;
            }
            else
            {
                FormView1.DefaultMode = FormViewMode.Edit;
            }
        }
    }
    protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
    {

    }
    protected void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        
    }
    protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName == "Cancel")
        {
            Response.Redirect("~/protected/ManagePages.aspx");
        }
    }
    protected void FormView1_ItemInserted(object sender, FormViewInsertedEventArgs e)
    {
        if (e.Exception != null && !e.ExceptionHandled)
        {
        }
        else
        {
            if (Page.IsValid)
                Response.Redirect("~/protected/ManagePages.aspx");
        }
    }

    protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
    {
        if(Page.IsValid && e.Exception == null)
            Response.Redirect("~/protected/ManagePages.aspx");
    }
}
